<?php
/**
 * Created by PhpStorm.
 * User: Xize
 * Date: 2018/4/25
 * Time: 16:43
 */
//创建Server对象，监听 127.0.0.1:9503端口，类型为SWOOLE_SOCK_UDP
$serv = new Swoole\Server("127.0.0.1", 9503, SWOOLE_BASE, SWOOLE_SOCK_UDP);
//监听数据发送事件
$serv->on('Packet', function ($serv, $data, $clientInfo) {
    //发送给客户端 用sendto
    $serv->sendto($clientInfo['address'], $clientInfo['port'], "Server ".$data);
    var_dump($data);
});
//启动服务器
$serv->start();